package com.longfa.ojbackendjudgeservice.codesandbox;

import com.longfa.ojbackendmodel.model.codesandbox.ExecuteCodeRequest;
import com.longfa.ojbackendmodel.model.codesandbox.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * ClassName: CodeSandboxProxy
 * Package: com.fa.oj.judge.codesandbox
 * Description: 代码沙箱能力增强 （这里使用设计模式的 代理模式）
 *
 * @Author:
 * @Create: 2024/4/23 - 17:50
 * @Version: v1.0
 */
@Slf4j
public class CodeSandboxProxy implements CodeSandbox{

    private CodeSandbox codeSandbox;

    public CodeSandboxProxy(CodeSandbox codeSandbox) {
        this.codeSandbox = codeSandbox;
    }
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("代码沙箱请求信息：" + executeCodeRequest.toString());
        ExecuteCodeResponse executeCodeResponse = codeSandbox.executeCode(executeCodeRequest);
        log.info("代码沙箱应答信息：" + executeCodeResponse.toString());
        return executeCodeResponse;
    }
}
